import subprocess
import os

def after_install():
    # 获取 hooks.py 所在目录的绝对路径
    current_dir = os.path.dirname(os.path.abspath(__file__))
    # 构建 requirements.txt 文件的相对路径
    requirements_file = os.path.join(current_dir, '..', 'requirements.txt')

    # 确保 requirements.txt 存在
    if os.path.exists(requirements_file):
        subprocess.check_call(["bench", "pip", "install", "-r", requirements_file])
    else:
        raise FileNotFoundError(f"Could not find requirements.txt at {requirements_file}")